<?php
require 'db.php';
// 乐观锁
// alter table count add column version char(20) default 0;
// 预处理 http://www.runoob.com/php/php-pdo-prepared-statements.html
$prefix = 'd1d';
$sql = 'select * from count where prefix = "dz10021"';
$data1 = $db->query($sql);
$data2 = $db->query($sql);
var_dump('===>>>> data 1');
var_dump($data1);
var_dump('===>>>> data 2');
var_dump($data2);
// 修改数据 1
$sql1 = 'update count set count = 13,version = version + 1 where prefix = "dz10021" and version = '.$data1['version'];
var_dump($db->execute($sql1));
// 修改数据 2
$sql2 = 'update count set count = 14,version = version + 1 where prefix = "dz10021" and version = '.$data2['version'];
var_dump($db->execute($sql2));


//  x锁
//goods_id 数量
// select * from goods where id  = xxx for update;
//
//
